<template>
  <div class="public-tab border-bottom">
    <div class="tab hover-style" 
      @click="handleTabClick(index)"
      v-for="(item,index) in tabs" :key="item.id"
      :class="index == activeIndex ? 'button-selected' : ''"
    >{{item.name}}</div> 
    <div class="extra">
      <slot></slot>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    tabs: {
      type: Array,
      default: function() {
        return [
          {
            id: 1,
            tabName: '我的钱包'
          },
          {
            id: 2,
            tabName: '安全设置'
          },
          {
            id: 3,
            tabName: '消息'
          },
          {
            id: 4,
            tabName: '操作日志'
          }
        ]
      }
    },
    activeIndex: {
      type: Number,
      default: 0
    }
  },
  methods: {
    handleTabClick(index) {
      this.$emit('click', index)
    }
  }
}
</script>

<style lang="stylus" scoped>
  .public-tab 
    height 60px 
    display flex 
    align-items center
    background #fbf9f9
    padding 0 20px
    .tab 
      box-sizing border-box 
      padding 10px
      display flex 
      font-size 15px 
      font-weight 700
      margin-right 10px 
    .extra 
      flex 1 
      display flex 
      justify-content flex-end 
</style>